//
//  AddCityLayout.m
//  UIA段项目 墨家天气
//
//  Created by dllo on 15/8/21.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "AddCityLayout.h"

@implementation AddCityLayout

-(void)dealloc
{
    [_dicArr release];
    [super dealloc];
}
-(instancetype)init
{
    self = [super init];
    if (self) {
        self.dicArr = [NSMutableArray array];
    }
    return self;
}


- (void)prepareLayout
{
    [super prepareLayout];
    
    NSInteger itemNum = [self.collectionView numberOfItemsInSection:0];
    for (int i = 0; i < itemNum; i ++) {

        NSIndexPath *index = [NSIndexPath  indexPathForRow:i inSection:0];
        UICollectionViewLayoutAttributes *att = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:index];


        att.frame = CGRectMake(i % 3 * ((self.collectionView.frame.size.width - 30 * OffWidth ) / 3)  + 20 * OffWidth, i / 3 * 150 * OffHeight  + 50 * OffHeight, ((self.collectionView.frame.size.width - 60 * OffWidth ) / 3), 140 * OffHeight);
        [self.dicArr addObject:att];
    }
    
    
    
    
    
    
    
    
}
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
    NSMutableArray *arr = [NSMutableArray array];
    for (UICollectionViewLayoutAttributes *att in self.dicArr) {
        
        [arr addObject:att];
      
    }
    
    return arr;
    
    
    
}
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return [self.dicArr objectAtIndex:indexPath.item];
}


@end
